﻿using TrackSystem.Entities.Extensions;
using TrackSystem.Entities.Models;
using TrackSystem.Entities.RequestFeatures;

namespace TrackSystem.Contracts
{
    public interface IVarRepository : IRepository<VarTable, int>
    {
        /// <summary>
        /// 以页为单位返回获取的变量信息
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        PagedList<VarTable> GetPagedVars(RequestParameter parameter);

        /// <summary>
        /// 获得传感器的所有变量表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<List<VarTable>> GetSensorRegsAsync(int id);

        /// <summary>
        /// 基于传感器添加变量表
        /// </summary>
        /// <param name="sensor">传感器类</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> UpdateBaseSensor(SensorTable sensor);

        /// <summary>
        /// 删除指定传感器ID的所有变量
        /// </summary>
        /// <param name="sensorId">传感器ID</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> DeleteBaseSensor(int sensorId);

        /// <summary>
        /// 基于通道添加变量表
        /// </summary>
        /// <param name="chn">传感器类</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> UpdateBaseChannel(ChannelTable chn);

        /// <summary>
        /// 删除指定通道ID的所有变量
        /// </summary>
        /// <param name="chnId">传感器ID</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> DeleteBaseChannel(int chnId);

        /// <summary>
        /// 基于逻辑添加相关变量
        /// </summary>
        /// <param name="logic">逻辑式ID号</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> UpdateBaseLogic(LogicTable logic);
        
        /// <summary>
        /// 删除逻辑相关变量
        /// </summary>
        /// <param name="logicId">逻辑式ID号</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> DeleteBaseLogic(int logicId);

        /// <summary>
        /// 删除回路相关变量
        /// </summary>
        /// <param name="loop">回路</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> UpdateBaseLoop(LoopTable loop);

        /// <summary>
        /// 删除指定回路ID的所有变量
        /// </summary>
        /// <param name="loopId">回路ID号</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> DeleteBasLoop(int loopId);
        
        /// <summary>
        /// 更新服务器相关变量
        /// </summary>
        /// <param name="slave">回路</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> UpdateBaseSlave(SlaveTable slave);

        /// <summary>
        /// 删除指定服务器ID的所有变量
        /// </summary>
        /// <param name="slaveId">回路ID号</param>
        /// <returns></returns>
        Task<ApiResult<VarTable>> DeleteBaseSlave(int slaveId);

        // ----------------------------------------------------------------------------
        Task<ApiResult<VarTable>> AddVarAsync(VarTable varTable);

        Task<ApiResult<VarTable>> UpdateVarAsync(VarTable varTable);

        Task<ApiResult<VarTable>> DeleteVarAsync(int varId);

        Task<Dictionary<string, DataTypeEnum>> GetNameTypeListAsync();
    }
}
